//
//  DBBaseNavigationController.swift
//  DBCA
//
//  Created by mugua on 2024/6/30.
//

import UIKit


class DBBaseNavigationController: UINavigationController, UINavigationControllerDelegate, UIGestureRecognizerDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        let titleTextAtt: [NSAttributedString.Key: Any] = [.foregroundColor : DBTextColor!,
                                                           .font : DBFuturaMaxiStd_DemiFont(15)
                                                          ]
        let barTintColor: UIColor = UIColor.white
        if #available(iOS 13.0, *) {
            let naviBarAppearance = UINavigationBarAppearance()
            naviBarAppearance.configureWithOpaqueBackground()
            naviBarAppearance.titleTextAttributes = titleTextAtt
            naviBarAppearance.shadowColor = .clear
            if self.navigationBar.isTranslucent {
                naviBarAppearance.backgroundColor = barTintColor.withAlphaComponent(1)
            } else {
                naviBarAppearance.backgroundColor = barTintColor
            }
            
            self.navigationBar.standardAppearance = naviBarAppearance
            self.navigationBar.scrollEdgeAppearance = naviBarAppearance
            let toolBarAppearance = UIToolbarAppearance()
            if self.toolbar.isTranslucent {
                toolBarAppearance.backgroundColor = barTintColor.withAlphaComponent(1)
            } else {
                toolBarAppearance.backgroundColor = barTintColor
            }
            
            self.toolbar.standardAppearance = toolBarAppearance
            if #available(iOS 15.0, *) {
                self.toolbar.scrollEdgeAppearance = toolBarAppearance
            }
        } else {
            let tabImg = UIImage.imageWithColor(color: UIColor.white)
            self.navigationBar.shadowImage = UIImage()
            self.navigationBar.setBackgroundImage(tabImg, for: .default)
            self.navigationBar.barTintColor = UIColor.clear
            self.navigationBar.titleTextAttributes = titleTextAtt
        }
        
        
        super.delegate = self
        self.navigationBar.isTranslucent = false
    }
    
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        
        
        
        super.pushViewController(viewController, animated: animated)
    }
    
    
    func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
    
        
    }
    
    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
        return self.children.count > 1
    }
    
    
    
}




